home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / menu_dvd.swf / scripts / __Packages / HtmlMenuCellRenderer.as < prev    next >
Text File  |  2007-11-07  |  3KB  |  89 lines

  1. class HtmlMenuCellRenderer extends mx.core.UIComponent
  2. {
  3.    static var style_sheet = null;
  4.    static var USE_EMBEDDED_FONT = true;
  5.    var previousLabel = null;
  6.    function HtmlMenuCellRenderer()
  7.    {
  8.       super();
  9.       this.cssStyle = "menuRowText";
  10.    }
  11.    function createChildren(Void)
  12.    {
  13.       if(HtmlMenuCellRenderer.CssUrl != undefined && HtmlMenuCellRenderer.style_sheet == null)
  14.       {
  15.          HtmlMenuCellRenderer.style_sheet = new TextField.StyleSheet();
  16.          HtmlMenuCellRenderer.style_sheet.load(HtmlMenuCellRenderer.CssUrl);
  17.       }
  18.       if(this.htmlComponent == undefined)
  19.       {
  20.          this.createLabel("htmlComponent",1);
  21.       }
  22.       this.htmlComponent.html = true;
  23.       this.htmlComponent.embedFonts = HtmlMenuCellRenderer.USE_EMBEDDED_FONT;
  24.       this.htmlComponent.border = false;
  25.       this.htmlComponent.multiline = false;
  26.       this.htmlComponent.wordWrap = false;
  27.       this.htmlComponent.selectable = false;
  28.       this.htmlComponent.styleSheet = HtmlMenuCellRenderer.style_sheet;
  29.       this._parent.drawRowFill = this.drawRowFill;
  30.       this.size();
  31.    }
  32.    function size(Void)
  33.    {
  34.       this.htmlComponent.setSize(this.__width,this.__height - 2);
  35.       var deltaY = 2;
  36.       this.htmlComponent._y = deltaY;
  37.    }
  38.    function setValue(str, item, sel)
  39.    {
  40.       if(item == undefined)
  41.       {
  42.          this.htmlComponent.htmlText = str;
  43.          this.previousLabel = null;
  44.          return undefined;
  45.       }
  46.       var columnIndex = this.columnIndex;
  47.       var columnName = this.getDataLabel();
  48.       var htmlTxt = str;
  49.       var labelSupSub = this.HtmlFunction(item.label);
  50.       htmlTxt = "<span class=\'" + this.cssStyle + "\'>" + labelSupSub + "</span>";
  51.       this.htmlComponent.htmlText = htmlTxt;
  52.    }
  53.    function getPreferredHeight(Void)
  54.    {
  55.       if(this.owner == undefined)
  56.       {
  57.          return 18;
  58.       }
  59.       return this.owner.__height;
  60.    }
  61.    function HtmlFunction(inLabel)
  62.    {
  63.       if(inLabel.indexOf("<sup>") >= 0 || inLabel.indexOf("<sub>") >= 0)
  64.       {
  65.          return StringUtils.subSupFromHTML(inLabel);
  66.       }
  67.       return inLabel;
  68.    }
  69.    function setColor(col)
  70.    {
  71.       if(this.htmlComponent != undefined)
  72.       {
  73.          this.htmlComponent.textColor = col;
  74.       }
  75.    }
  76.    function drawRowFill(mc, newClr)
  77.    {
  78.       mc.clear();
  79.       mc.beginFill(16777215);
  80.       mc.drawRect(0,0,this.__width,this.__height);
  81.       mc.beginFill(newClr);
  82.       mc.drawRect(0,1,this.__width,this.__height);
  83.       mc.endFill();
  84.       mc._width = this.__width;
  85.       mc._height = this.__height;
  86.       mc._alpha = 90;
  87.    }
  88. }
  89.